#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from LoopTestSequence import LoopTestSequence
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU


#  This test verifies that a standard loop can execute a wide variety of
#  instructions and still
# terminate successfully.
class MainSequence(LoopTestSequence):
    def __init__(self, gen_thread, name=None):
        super().__init__(gen_thread, name)

        self._mInstructionWeights = {
            "ADD##CALM": 10,
            "ADDI##CALM": 10,
            "ADDIW##CALM": 10,
            "ADDW##CALM": 10,
            "AND##CALM": 10,
            "ANDI##CALM": 10,
            "AUIPC##CALM": 10,
            # 'BEQ##CALM': 10,
            # 'BGE##CALM': 10,
            # 'BGEU##CALM': 10,
            # 'BLT##CALM': 10,
            # 'BLTU##CALM': 10,
            # 'BNE##CALM': 10,
            "DIV##CALM": 10,
            "DIVU##CALM": 10,
            "DIVUW##CALM": 10,
            "DIVW##CALM": 10,
            "JAL##CALM": 10,
            "JALR##CALM": 10,
            # 'LB##CALM': 10,
            # 'LBU##CALM': 10,
            # 'LD##CALM': 10,
            # 'LH##CALM': 10,
            # 'LHU##CALM': 10,
            "LUI##CALM": 10,
            # 'LW##CALM': 10,
            # 'LWU##CALM': 10,
            "MUL##CALM": 10,
            "MULH##CALM": 10,
            "MULHSU##CALM": 10,
            "MULHU##CALM": 10,
            "MULW##CALM": 10,
            "OR##CALM": 10,
            "ORI##CALM": 10,
            "REM##CALM": 10,
            "REMU##CALM": 10,
            "REMUW##CALM": 10,
            "REMW##CALM": 10,
            # 'SB##CALM': 10,
            # 'SD##CALM': 10,
            # 'SH##CALM': 10,
            "SLL##CALM": 10,
            "SLLI#RV64I#CALM": 10,
            "SLLIW##CALM": 10,
            "SLLW##CALM": 10,
            "SLT##CALM": 10,
            "SLTI##CALM": 10,
            "SLTIU##CALM": 10,
            "SLTU##CALM": 10,
            "SRA##CALM": 10,
            "SRAI#RV64I#CALM": 10,
            "SRAIW##CALM": 10,
            "SRAW##CALM": 10,
            "SRL##CALM": 10,
            "SRLI#RV64I#CALM": 10,
            "SRLIW##CALM": 10,
            "SRLW##CALM": 10,
            "SUB##CALM": 10,
            "SUBW##CALM": 10,
            # 'SW##CALM': 10,
            "XOR##CALM": 10,
            "XORI##CALM": 10,
        }

        if self.getGlobalState("AppRegisterWidth") == 32:
            self._mInstructionWeights = {
                "ADD##CALM": 10,
                "ADDI##CALM": 10,
                "AND##CALM": 10,
                "ANDI##CALM": 10,
                "AUIPC##CALM": 10,
                # 'BEQ##CALM': 10,
                # 'BGE##CALM': 10,
                # 'BGEU##CALM': 10,
                # 'BLT##CALM': 10,
                # 'BLTU##CALM': 10,
                # 'BNE##CALM': 10,
                "DIV##CALM": 10,
                "DIVU##CALM": 10,
                "JAL##CALM": 10,
                "JALR##CALM": 10,
                # 'LB##CALM': 10,
                # 'LBU##CALM': 10,
                # 'LH##CALM': 10,
                # 'LHU##CALM': 10,
                "LUI##CALM": 10,
                # 'LW##CALM': 10,
                # 'LWU##CALM': 10,
                "MUL##CALM": 10,
                "MULH##CALM": 10,
                "MULHSU##CALM": 10,
                "MULHU##CALM": 10,
                "OR##CALM": 10,
                "ORI##CALM": 10,
                "REM##CALM": 10,
                "REMU##CALM": 10,
                # 'SB##CALM': 10,
                # 'SH##CALM': 10,
                "SLL##CALM": 10,
                "SLLI#RV32I#CALM": 10,
                "SLT##CALM": 10,
                "SLTI##CALM": 10,
                "SLTIU##CALM": 10,
                "SLTU##CALM": 10,
                "SRA##CALM": 10,
                "SRAI#RV32I#CALM": 10,
                "SRL##CALM": 10,
                "SRLI#RV32I#CALM": 10,
                "SUB##CALM": 10,
                # 'SW##CALM': 10,
                "XOR##CALM": 10,
                "XORI##CALM": 10,
            }

    # Return a dictionary of names of instructions to generate in the loop
    # body with their corresponding weights.
    def getInstructionWeights(self):
        return self._mInstructionWeights


MainSequenceClass = MainSequence
GenThreadClass = GenThreadGPGPU
EnvClass = EnvGPGPU
